package main

import "fmt"

func divideZero(ch chan int) {
	defer func () {
		if err := recover(); err != nil {
			fmt.Println(err)
			// 要给管道传值，否则主线程从空管道里取值会阻塞，形成死锁
			ch <- 0
		}
	}()
	zero := 0
	ch <- 1 / zero
}

func main() {
	ch := make(chan int)
	go divideZero(ch)
	<- ch
}